<?php

include ("config.php");

function fix_magic_crap()
{
        // Fuck off with your crap magic quotes:
        if (get_magic_quotes_gpc() == 0)
                return;

        // Only do it once:
        if (defined('CRAPFIXED'))
                return;

        define('CRAPFIXED',1);

        // It's set, remove it from all variables:
        fix_magic_crap_array($_GET);
        fix_magic_crap_array($_POST);
        fix_magic_crap_array($_COOKIE);
        fix_magic_crap_array($_REQUEST);
}


function fix_magic_crap_array(&$array)
{
        foreach ($array as &$val) {
                if (is_array($val))
                        fix_magic_crap_array($val);
                else
                        $val = stripslashes($val);
        }
}


fix_magic_crap();

//if (get_magic_quotes_gpc()) die ("magic quotes must be disabled");

function connect_db()
{
	global $dbhost, $dbuser, $dbpass, $dbname;

	$db = mysql_connect($dbhost, $dbuser, $dbpass);
	if (!$db) 
		die("could not connect to database");
	mysql_select_db($dbname, $db);
	return $db;
}


function generate_menu()
{
	$out = '';
	$out .= '<table>'. "\n" ;
	$out .= '<tr><td><a href="view_all.php">Overview</a></td><td><a href="view_lang.php">Languages</a></td><td><a href="view_field.php">Variables</a></td></tr>' . "\n";
	$out .= '</table>'. "\n" ;
	return $out;
}



function get_header()
{
	$out = <<<HD1
<html><header><title></title></header>
<body>
HD1;
	return $out;
} 


function get_footer()
{
	$out = <<<FT1
</body>
</html>
FT1;
	return $out;
} 
?>
